package com.android.demo.widget;

import java.util.Calendar;

public class EpochDate {
	private long windwosEpoch;
	private Calendar calendar;
	
	private final static long EPOCH_DIFF = 11644473600000L;
	
	public EpochDate(long windwosEpoch) {
		this.windwosEpoch = windwosEpoch;
		calendar = Calendar.getInstance();
		calendar.setTimeInMillis(windwosEpoch - EPOCH_DIFF);
	}
	
	public EpochDate(Calendar calendar) {
		this.calendar = calendar;
		this.windwosEpoch = calendar.getTimeInMillis() + EPOCH_DIFF;
	}
	
	public long getWindowsEpoch() {
		return this.windwosEpoch;
	}
	
	public Calendar getCalendar() {
		return this.calendar;
	}
	
	public void setWindowsEpoch(long windowsEpoch) {
		this.windwosEpoch = windowsEpoch;
		this.calendar.setTimeInMillis(windwosEpoch - EPOCH_DIFF);
	}
	
	public void setCalendar(Calendar calendar) {
		this.calendar = calendar;
		this.windwosEpoch = calendar.getTimeInMillis() + EPOCH_DIFF;
	}

}
